jsx3.Class.defineClass(
        "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView", //the full name of the class to create
        jsx3.lang.Object, //  extends
        [tibco.admin.monitormanage.framework.mainPage.MainPageInterface,tibco.admin.plugin.PluginContainerInterface], // implements
        function (plugin) {
        	plugin.wsEndpointURL = tibco.admin.monitormanage.framework.mainPage.MainPage.wsEndpointURL;

        	plugin.searchServicesScreenId = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.searchServicesScreen";
        	plugin.serviceScreenId = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceScreen";
        	plugin.serviceInstanceScreenId = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceInstanceScreen";

        	plugin.serviceInfoCacheSubject = "com.tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceInfoCache";
        	plugin.serviceInstanceInfoCacheSubject = "com.tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView.serviceInstanceInfoCache";

        	plugin.serviceInfoCacheId = "SPM_SERVICE_SCREEN_CACHE";
        	plugin.serviceInstanceInfoCacheId = "SPM_SERVICE_INSTANCE_SCREEN_CACHE";

        	plugin.serviceHeaderInterfaceClassName = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceHeaderInterface";
        	plugin.serviceTabInterfaceClassName = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceTabInterface";
        	plugin.serviceInstanceHeaderInterfaceClassName = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceInstanceHeaderInterface";
        	plugin.serviceInstanceTabInterfaceClassName = "tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceInstanceTabInterface";

            plugin.instance = null;

            plugin.prototype.searchServicesScreen = null;
            plugin.prototype.serviceScreen = null;
            plugin.prototype.serviceInstanceScreen = null;
            plugin.prototype.currentlyDisplayedScreen = null;

            plugin.prototype.loadingPluginsDuringServiceInstanceMode;

            plugin.prototype.serviceId = null;
            plugin.prototype.serviceInstanceId = null;

            plugin.prototype.allTabs = new Object();
            plugin.prototype.tabsToLoad = new Object();

            plugin.prototype.pluginsLoaded = false;
            plugin.prototype.displayScreenWaiting = false;
		    plugin.prototype.screenIdWaiting;
		    plugin.prototype.parameterArrayWaiting;

            plugin.getInstance = function(args) {
                if(!this.instance) {
                    this.instance = new tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceView();
                }
                return this.instance;
            }

            plugin.prototype.getNamespace = function() {
               return "tibco.admin";
            }

            plugin.prototype.getComponentPath = function() {
                return  "tibco/admin/monitormanage/uicomponents/page/serviceView/component.xml"
            }

            plugin.prototype.getTabText = function() {
				return tibco.admin.Main.getServer().getDynamicProperty("@MM@general@ServiceViewTitle");
            	//return "Service View";
            }

            plugin.prototype.getDefaultScreenId = function() {
        		return plugin.searchServicesScreenId;
        	}

            plugin.prototype.getScreenIds = function() {
            	return [plugin.serviceScreenId, plugin.serviceInstanceScreenId, plugin.searchServicesScreenId];
        	}

            plugin.prototype.loadComponent = function(parent) {
            	this.allTabs = new Object();
	            this.serviceScreen = null;
	            this.serviceInstanceScreen = null;
	            this.loadingPluginsDuringServiceInstanceMode = null;
	            this.serviceId = null;
	            this.serviceInstanceId = null;
	            this.tabsToLoad = new Object();
	            this.pluginsLoaded = false;
	            this.displayScreenWaiting = false;
			    this.screenIdWaiting = null;
			    this.parameterArrayWaiting = null;

                this.block = tibco.admin.Main.loadUIResource(parent, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/components/serviceView.xml", true);

                this.searchServicesScreen = new jsx3.gui.Block("searchServicesScreen", 0, 0, "100%", "100%");
                this.block.setChild(this.searchServicesScreen);
                this.currentlyDisplayedScreen = this.searchServicesScreen;
            }

            plugin.prototype.setupPlugin = function(obj) {
            }

            plugin.prototype.onAfterGetPlugins = function() {
                var serviceTabInterfaceClassName;
                var serviceHeaderInterfaceClassName;
                var isServiceInstanceMode;
                var screenIdVal;
                if(this.loadingPluginsDuringServiceInstanceMode)
                {
                	serviceTabInterfaceClassName = plugin.serviceInstanceTabInterfaceClassName;
                	serviceHeaderInterfaceClassName = plugin.serviceInstanceHeaderInterfaceClassName;
                	isServiceInstanceMode = true;
                	screenIdVal = plugin.serviceInstanceScreenId;
                }
                else
                {
                	serviceTabInterfaceClassName = plugin.serviceTabInterfaceClassName;
                	serviceHeaderInterfaceClassName = plugin.serviceHeaderInterfaceClassName;
                	isServiceInstanceMode = false;
                	screenIdVal = plugin.serviceInstanceScreenId;
                }

                var headerPane;
                var tabpane;
	            var iter = this.getPluginList().iterator();
	            var first = true;
	            while(iter.hasNext()) {
	                 var obj = iter.next();

	                 var isServiceTabInterface = jsx3.Class.forName(serviceTabInterfaceClassName).isInstance(obj);
	                 var isServiceHeaderInterface = jsx3.Class.forName(serviceHeaderInterfaceClassName).isInstance(obj);

	                 if(isServiceTabInterface)
	                 {
	            	 	var tabIdPrefix = null;
	                	var tabbedPaneName = null;
    	            	if(isServiceInstanceMode)
        	        	{
            	    		tabbedPaneName = "serviceInstanceTabbedPane";
                			tabIdPrefix = "serviceInstance";
                		}
                		else
                		{
                			tabIdPrefix = "service";
		                	tabbedPaneName = "serviceTabbedPane";
                		}
                		tabpane = this.block.getDescendantOfName(tabbedPaneName);
                	    	var tabId = tabIdPrefix + "_tab_" + obj.getTabText();
                	    	this.allTabs[tabId] = obj;
				var tab = new com.gix.gui.Tab(tabId,null,null,null,obj.getTabText());
                        tab.subscribe(jsx3.gui.Interactive.EXECUTE, this, this.loadTab);
    				  //  tab.subscribe(jsx3.gui.Interactive.SHOW,this,this.loadTab)
						tabpane.setChild(tab);
                       /* tab.setBackgroundColor("");
					    tab.getContentChild().setBackgroundColor("#ffffff");
						tab.getContentChild().setBorder("solid 1px black");
                     */
                        if(first) {
   	                		// TODO: this next line assumes the Overview tab is always first which
   	                		// is a poor assumption.
   	                		obj.setIsServiceInstanceMode(isServiceInstanceMode);

       	            	    obj.loadComponent(tab.getContentPane());
           	        	    first = false;
               	    	}
                   		else {
                   		    this.tabsToLoad[tabId] = obj;
               		 	}

                  	}
                   	else if(isServiceHeaderInterface)
                   	{
                   		var headerPaneName = null;
	                	if(isServiceInstanceMode)
               			{ headerPaneName = "serviceInstanceHeaderPluginPane"; }
               			else
               			{ headerPaneName = "serviceHeaderPluginPane"; }
               			headerPane = this.block.getDescendantOfName(headerPaneName);

               			// construct the parent block for the plugin component
               			var parentBlock = new jsx3.gui.Block("pluginParentBlock", 0, 0, obj.getPluginComponentWidth(), "100%");
               			parentBlock.setCSSOverride("float:left");
               			headerPane.setChild(parentBlock);

                		obj.loadComponent(parentBlock);
                   	}
                 }
                 if(headerPane)
                 { headerPane.repaint(); }
                 if(tabpane)
                 { tabpane.repaint(); }

				// now check to see if the displayScreen call is waiting for the loaded plugins
				this.pluginsLoaded = true;
				if(this.displayScreenWaiting)
				{
					this.displayScreenWaiting = false;
					this.displayScreen(this.screenIdWaiting, this.parameterArrayWaiting);
				}

            }

            plugin.prototype.loadTab = function(objEvent) {
               var tabObj = objEvent.target;
               var tabIdPrefix = "service";
               if(tabObj.getAncestorOfName("serviceInstanceBlock"))
               { tabIdPrefix = "serviceInstance"; }
               var tabId = tabIdPrefix + '_tab_' + tabObj.getText();
                if(this.tabsToLoad[tabId]) {
                    var obj = this.tabsToLoad[tabId];
                    if(obj) {    
                        obj.loadComponent(objEvent.target.getContentPane());
                        delete this.tabsToLoad[tabId];
                    }
                }
                this.allTabs[tabId].tabClicked();
            }

            plugin.prototype.buildScreen = function(screenId, parameterArray) {
            	if(screenId == plugin.searchServicesScreenId)
            	{
					tibco.admin.Main.loadResource("tibco/admin/monitormanage/uicomponents/page/serviceView/jss/servicesJSS.xml", this.getNamespace(), "SPM_SERVICES_JSS_CACHE", "jss", true);
	                tibco.admin.Main.loadUIResource(this.searchServicesScreen, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/components/searchServices.xml", true);

	                var timeframePane = this.searchServicesScreen.getDescendantOfName("timeframePane");
	                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.dropdown || !tibco.admin.monitormanage.uicomponents.dropdown.timeframe || !tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe)
	                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/dropdown/timeframe/Timeframe.js", this.getNamespace()); }
	                var timeframeDropdown = tibco.admin.Main.loadUIResource(timeframePane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/dropdown/timeframe/components/timeframe.xml", true);
	                timeframeDropdown.setUpComponent("_MM_svc", false);

	              /*  var breadcrumbPane = this.searchServicesScreen.getDescendantOfName("breadcrumbPane");
	                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.misc || !tibco.admin.monitormanage.uicomponents.misc.breadcrumb || !tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb)
	                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/misc/breadcrumb/Breadcrumb.js", this.getNamespace()); }
	                var bc = tibco.admin.Main.loadUIResource(breadcrumbPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/misc/breadcrumb/components/breadcrumb.xml", true);
					//bc.displayBreadCrumbBlock();*/

					var searchPane = this.searchServicesScreen.getDescendantOfName("searchPane");
	                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.misc || !tibco.admin.monitormanage.uicomponents.misc.serviceSearch || !tibco.admin.monitormanage.uicomponents.misc.serviceSearch.ServiceSearch)
	                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/misc/serviceSearch/ServiceSearch.js", this.getNamespace()); }
	                var serviceSearch = tibco.admin.Main.loadUIResource(searchPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/misc/serviceSearch/components/serviceSearch.xml", true);
	                serviceSearch.setUpComponent();

	                var servicesPane = this.searchServicesScreen.getDescendantOfName("contentPane");
	        		if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.table || !tibco.admin.monitormanage.uicomponents.table.services || !tibco.admin.monitormanage.uicomponents.table.services.Services)
	               	{ tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/table/services/Services.js", this.getNamespace()); }
	               	var servicesComponent = tibco.admin.Main.loadUIResource(servicesPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/table/services/components/services.xml", true);
	                servicesComponent.setUpComponent("_MM_svc", plugin.searchServicesScreenId,false);
                }
        		if(screenId == plugin.serviceScreenId)
        		{
        			tibco.admin.monitormanage.general.PollingHandler.register(tibco.admin.monitormanage.general.PollingHandler.GENERAL_POLLING_HANDLER_ID, this, this.updateComponent, plugin.serviceScreenId);
        			tibco.admin.monitormanage.general.RefreshHandler.register(this, this.updateComponent, plugin.serviceScreenId);
        			tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.selectedTimeframeSubject, this.timeframeSelected, this);

        			this.serviceId = parameterArray.serviceId;

        			// load the service screen
        			this.serviceScreen = new jsx3.gui.Block("serviceScreen", 0, 0, "100%", "100%");
        			this.block.setChild(this.serviceScreen);
        			var serviceBlock = tibco.admin.Main.loadUIResource(this.serviceScreen, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/components/service.xml", true);

                    var timeframePane = serviceBlock.getDescendantOfName("timeframePane");
                    if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.dropdown || !tibco.admin.monitormanage.uicomponents.dropdown.timeframe || !tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe)
                    { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/dropdown/timeframe/Timeframe.js", this.getNamespace()); }
                    var timeframeDropdown = tibco.admin.Main.loadUIResource(timeframePane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/dropdown/timeframe/components/timeframe.xml", true);
                    timeframeDropdown.setUpComponent("_MM_svc", false, plugin.serviceScreenId);

                    var breadcrumbPane = serviceBlock.getDescendantOfName("breadcrumbPane");
                    if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.misc || !tibco.admin.monitormanage.uicomponents.misc.breadcrumb || !tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb)
                	{ tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/misc/breadcrumb/Breadcrumb.js", this.getNamespace()); }
                    var bc = tibco.admin.Main.loadUIResource(breadcrumbPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/misc/breadcrumb/components/breadcrumb.xml", true);
                    bc.setUpComponent("_MM_svc", true, tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.displayTypeService, plugin.serviceInfoCacheSubject, plugin.serviceInfoCacheId);
                    //bc.setUpComponent(true, tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.displayTypeService, plugin.serviceInfoCacheSubject, plugin.serviceInfoCacheId);

                	var serviceHeaderPane = serviceBlock.getDescendantOfName("serviceHeaderPane");
        			if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.text || !tibco.admin.monitormanage.uicomponents.text.serviceHeader || !tibco.admin.monitormanage.uicomponents.text.serviceHeader.ServiceHeader)
                	{ tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/text/serviceHeader/ServiceHeader.js", this.getNamespace()); }
                	var serviceHeaderObj = tibco.admin.Main.loadUIResource(serviceHeaderPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/text/serviceHeader/components/serviceHeader.xml", true);
                	serviceHeaderObj.setUpComponent();

                    // load the plugins
				    var interfaceList = this.getInterfaceList();
                    var preloadList = this.getPreloadList();
                    this.loadingPluginsDuringServiceInstanceMode = false;
                    this.loadPlugins(interfaceList, preloadList);
        		}
        		else if(screenId == plugin.serviceInstanceScreenId)
        		{
        			tibco.admin.monitormanage.general.PollingHandler.register(tibco.admin.monitormanage.general.PollingHandler.GENERAL_POLLING_HANDLER_ID, this, this.updateComponent, plugin.serviceInstanceScreenId);
        			tibco.admin.monitormanage.general.RefreshHandler.register(this, this.updateComponent, plugin.serviceInstanceScreenId);
        			tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.selectedTimeframeSubject, this.timeframeSelected, this);

        			this.serviceInstanceId = parameterArray.serviceInstanceId;

        			// load the service instance screen
	        		this.serviceInstanceScreen = new jsx3.gui.Block("serviceInstanceScreen", 0, 0, "100%", "100%");
	        		this.block.setChild(this.serviceInstanceScreen);
	        		var serviceInstanceBlock = tibco.admin.Main.loadUIResource(this.serviceInstanceScreen, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/components/serviceInstance.xml", true);

	                var timeframePane = serviceInstanceBlock.getDescendantOfName("timeframePane");
	                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.dropdown || !tibco.admin.monitormanage.uicomponents.dropdown.timeframe || !tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe)
	                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/dropdown/timeframe/Timeframe.js", this.getNamespace()); }
	                var timeframeDropdown = tibco.admin.Main.loadUIResource(timeframePane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/dropdown/timeframe/components/timeframe.xml", true);
	                timeframeDropdown.setUpComponent("_MM_svc", false, plugin.serviceInstanceScreenId);

	                var logicalBreadcrumbPane = serviceInstanceBlock.getDescendantOfName("logicalBreadcrumbPane");
	                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.misc || !tibco.admin.monitormanage.uicomponents.misc.breadcrumb || !tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb)
	                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/misc/breadcrumb/Breadcrumb.js", this.getNamespace()); }
	                var logicalBC = tibco.admin.Main.loadUIResource(logicalBreadcrumbPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/misc/breadcrumb/components/breadcrumb.xml", true);
	  				logicalBC.setUpComponent("_MM_svc", true, tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.displayTypeService, plugin.serviceInstanceInfoCacheSubject, plugin.serviceInstanceInfoCacheId);
	  				//logicalBC.setUpComponent(true, tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.displayTypeService, plugin.serviceInstanceInfoCacheSubject, plugin.serviceInstanceInfoCacheId);

	  				var physicalBreadcrumbPane = serviceInstanceBlock.getDescendantOfName("physicalBreadcrumbPane");
	                var physicalBC = tibco.admin.Main.loadUIResource(physicalBreadcrumbPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/misc/breadcrumb/components/breadcrumb.xml", true);
	  				physicalBC.setUpComponent("_MM_svc", false, tibco.admin.monitormanage.uicomponents.misc.breadcrumb.Breadcrumb.displayTypeService, plugin.serviceInstanceInfoCacheSubject, plugin.serviceInstanceInfoCacheId, true);

	                var serviceInstanceHeaderPane = serviceInstanceBlock.getDescendantOfName("serviceInstanceHeaderPane");
	        		if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.text || !tibco.admin.monitormanage.uicomponents.text.serviceInstanceHeader || !tibco.admin.monitormanage.uicomponents.text.serviceInstanceHeader.ServiceInstanceHeader)
	                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/text/serviceInstanceHeader/ServiceInstanceHeader.js", this.getNamespace()); }
	                var headerPane = tibco.admin.Main.loadUIResource(serviceInstanceHeaderPane, this.getNamespace(), "tibco/admin/monitormanage/uicomponents/text/serviceInstanceHeader/components/serviceInstanceHeader.xml", true);
	                headerPane.setUpComponent();

					// load the plugins
					var interfaceList = this.getInterfaceList();
	                var preloadList = this.getPreloadList();
	                this.loadingPluginsDuringServiceInstanceMode = true;
	                this.loadPlugins(interfaceList, preloadList);
        		}
        	}

        	plugin.prototype.getPreloadList = function() {
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.overview || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.overview.Overview)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/tabContent/overview/Overview.js", this.getNamespace()); }
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.operations || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.operations.Operations)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/tabContent/operations/Operations.js", this.getNamespace()); }
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.providesConsumes || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.providesConsumes.ProvidesConsumes)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/tabContent/providesConsumes/ProvidesConsumes.js", this.getNamespace()); }
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.deployment || !tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.deployment.Deployment)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/tabContent/deployment/Deployment.js", this.getNamespace()); }

                var preloadList = new jsx3.util.List();
                preloadList.add(tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.overview.Overview);
                preloadList.add(tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.operations.Operations);
                preloadList.add(tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.providesConsumes.ProvidesConsumes);
                preloadList.add(tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.deployment.Deployment);
                
                try {
                    if (!tibco.admin.monitormanage || !tibco.admin.monitormanage.serviceHeaderButton || !tibco.admin.monitormanage.serviceHeaderButton.ServiceHeaderButton)
                    { tibco.admin.Main.loadClass("tibco/admin/monitormanage/serviceHeaderButton/ServiceHeaderButton.js", this.getNamespace()); }
                    preloadList.add(tibco.admin.monitormanage.serviceHeaderButton.ServiceHeaderButton);
                }
                catch(ex) {
                    tibco.admin.Main.loadException(ex);
                }
                /*
                try {
                    if (!tibco.admin.monitormanage || !tibco.admin.monitormanage.logCfg || !tibco.admin.monitormanage.logCfg.LogCfg)
                    { tibco.admin.Main.loadClass("tibco/admin/monitormanage/logCfg/LogCfg.js", this.getNamespace()); }
                    preloadList.add(tibco.admin.monitormanage.logCfg.LogCfg);
                }
                catch(ex) {
                    tibco.admin.Main.loadException(ex);
                }
                */

                try {
                    if (!tibco.admin.monitormanage || !tibco.admin.monitormanage.uddiPub || !tibco.admin.monitormanage.uddiPub.UddiPub)
                    { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uddiPub/UddiPub.js", this.getNamespace()); }
                    preloadList.add(tibco.admin.monitormanage.uddiPub.UddiPub);
                }
                catch(ex) {
                    tibco.admin.Main.loadException(ex);
                }

                return preloadList;
        	}

        	plugin.prototype.getInterfaceList = function() {
	        	// handle the plugin components
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceTabInterface)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/ServiceTabInterface.js", this.getNamespace()); }
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceInstanceTabInterface)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/ServiceInstanceTabInterface.js", this.getNamespace()); }
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceHeaderInterface)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/ServiceHeaderInterface.js", this.getNamespace()); }
                if(!tibco.admin.monitormanage || !tibco.admin.monitormanage.uicomponents || !tibco.admin.monitormanage.uicomponents.page || !tibco.admin.monitormanage.uicomponents.page.serviceView || !tibco.admin.monitormanage.uicomponents.page.serviceView.ServiceInstanceHeaderInterface)
                { tibco.admin.Main.loadClass("tibco/admin/monitormanage/uicomponents/page/serviceView/ServiceInstanceHeaderInterface.js", this.getNamespace()); }

	    		var interfaceList = new jsx3.util.List();
	    		interfaceList.add(plugin.serviceTabInterfaceClassName);
	    		interfaceList.add(plugin.serviceInstanceTabInterfaceClassName);
	    		interfaceList.add(plugin.serviceHeaderInterfaceClassName);
	    		interfaceList.add(plugin.serviceInstanceHeaderInterfaceClassName);

	    		return interfaceList;

        	}

        	plugin.prototype.updateComponent = function() {
        		if(this.currentlyDisplayedScreen == this.serviceScreen)
				{ this.callGetServices(); }
				else if(this.currentlyDisplayedScreen == this.serviceInstanceScreen)
				{ this.callGetServiceInstances(); }
			}

			plugin.prototype.timeframeSelected = function(subject, message, viewObj) {
            	var timeframeId = message.selectedTimeframe;
            	if(viewObj.currentlyDisplayedScreen == viewObj.serviceScreen)
				{ viewObj.callGetServices(timeframeId); }
				else if(viewObj.currentlyDisplayedScreen == viewObj.serviceInstanceScreen)
				{ viewObj.callGetServiceInstances(timeframeId); }
            }

        	plugin.prototype.displayScreen = function(screenIdVal, parameterArray) {
        		if(this.pluginsLoaded || screenIdVal == plugin.searchServicesScreenId)
        		{
	        		this.currentlyDisplayedScreen.setDisplay(jsx3.gui.Block.DISPLAYNONE);
	        		var server = tibco.admin.Main.getServer();
	        		var isService = false;
	        		var isServiceInstance = false;
	        		var idForPluginClass;
	        		var message = {screenId:screenIdVal};
					if(screenIdVal == plugin.serviceScreenId)
					{
						isService = true;
						idForPluginClass = parameterArray.serviceId
						message.serviceId = parameterArray.serviceId;
						var consumerProviderKey = parameterArray.consumerProviderKey;
						if(consumerProviderKey && consumerProviderKey != "")
						{
							message.consumerProviderKey = consumerProviderKey;
							message.isInterfaceConsumersMode = parameterArray.isInterfaceConsumersMode;

                        }
						this.currentlyDisplayedScreen = this.serviceScreen;
						this.serviceId = parameterArray.serviceId;
						this.callGetServices(null, true, message);
					}
					else if(screenIdVal == plugin.serviceInstanceScreenId)
					{
						isServiceInstance = true;
						idForPluginClass = parameterArray.serviceInstanceId;
						message.serviceInstanceId = parameterArray.serviceInstanceId;
						this.serviceInstanceId = parameterArray.serviceInstanceId;
						this.currentlyDisplayedScreen = this.serviceInstanceScreen;
						this.callGetServiceInstances(null, true);
					}
					else if(screenIdVal == plugin.searchServicesScreenId)
					{  var breadCrumbObj=this.searchServicesScreen.getDescendantOfName("breadcrumbPane");

                        var separator = server.getDynamicProperty("@MM@general@breadSeparator");
                        // TODO: add the proper parameters for the Search Services screen
                       if(parameterArray)  {
                        isServiceInstance= parameterArray.isServiceInstance;
                    if(isServiceInstance) {
                               message.isServiceInstance=isServiceInstance=true;
                              var breadcrumbText="";
                              message.nodeId=parameterArray.nodeId;
                              message.nodeName=parameterArray.nodeName;
                              message.environmentId = parameterArray.environmentId;
                              message.environmentName = parameterArray.environmentName;
                              message.machineId=parameterArray.machineId;
                              message.machineName=parameterArray.machineName;

                             if(message.environmentName!=undefined){
                                   breadcrumbText=message.environmentName + server.getDynamicProperty("@MM@general@environmentLabel");
                                 if(message.machineName!=undefined){
                                    breadcrumbText += separator;
                                    breadcrumbText += message.machineName;
                                         if(message.nodeName!=undefined){
                                          breadcrumbText += separator;
                                          breadcrumbText += message.nodeName;
                                      }
                                }
                            }
                          breadCrumbObj.setText(breadcrumbText);
                          breadCrumbObj.repaint();
                          }
                           else{
                                     message.isServiceInstance=isServiceInstance=false;
                                      var breadcrumbText="";
                                      message.environmentId = parameterArray.environmentId;
                                      message.environmentName = parameterArray.environmentName;
                                      message.serviceAssemblyId = parameterArray.serviceAssemblyId;
                                      message.serviceAssemblyName = parameterArray.serviceAssemblyName;
                                      message.serviceUnitId = parameterArray.serviceUnitId;
                                      message.serviceUnitName = parameterArray.serviceUnitName;

                                     if(message.environmentName!=undefined){
                                         breadcrumbText=message.environmentName + server.getDynamicProperty("@MM@general@environmentLabel");
                                         if(message.serviceAssemblyName!=undefined){
                                             breadcrumbText += separator;
                                             breadcrumbText += message.serviceAssemblyName;
                                                 if(message.serviceUnitName!=undefined){
                                                  breadcrumbText += separator;
                                                  breadcrumbText += message.serviceUnitName;
                                              }
                                        }
                                    }
                          breadCrumbObj.setText(breadcrumbText);
                          breadCrumbObj.repaint();
                           }
                          message.isFrmBrowse=true;

                         }
                        else{

                          breadCrumbObj.setText("");
                          breadCrumbObj.repaint();
                       }

                        message.screenIdVal=screenIdVal;
                        this.currentlyDisplayedScreen = this.searchServicesScreen;
                    }

					// notify the components that they need to display
					tibco.admin.monitormanage.general.PageBusUtils.publish(tibco.admin.monitormanage.general.NavigationHandler.mainPageDisplayTopic, message);

					this.currentlyDisplayedScreen.setDisplay(jsx3.gui.Block.DISPLAYBLOCK);
		        	this.block.repaint();
		        }
		        else
		        {
		        	this.displayScreenWaiting = true;
		        	this.screenIdWaiting = screenIdVal;
		        	this.parameterArrayWaiting = parameterArray;
		        }
        	}

        	plugin.prototype.mainPageTabSelected = function() {
			//Clear any existing data
						var cache = tibco.admin.Main.getServer().Cache.getDocument("SPM_SERVICE_SEARCH_SCREEN_CACHE");
						if (cache) {
							cache.getRootNode().removeChildren();
						}
        		/*
        		// the main page tab was selected...make sure we go to the search services screen
        		if(this.searchServicesScreen.getDisplay() == jsx3.gui.Block.DISPLAYNONE)
        		{
        			this.currentlyDisplayedScreen.setDisplay(jsx3.gui.Block.DISPLAYNONE);
        			this.currentlyDisplayedScreen = this.searchServicesScreen;
        			this.searchServicesScreen.setDisplay(jsx3.gui.Block.DISPLAYBLOCK);
        			this.block.repaint();
        		}
        		*/
        	}

        	//call this method to begin the service call (eg.service.callgetServices();)
    		plugin.prototype.callGetServices = function(timeframeId, updatePlugins, pluginMessage) {
                  if(tibco.admin.Main.getServer().getEnv("MODE"))
    			{
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/rules/serviceScreenRules.xml", "getServices");
					objService.setEndpointURL(plugin.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL("tibco/admin/monitormanage/uicomponents/page/serviceView/data/serviceScreenData.xml");
				}
				else
				{
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/rules/serviceScreenRules.xml"), "getServices", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/data/serviceScreenData.xml"));
				}
				
				objService.serviceViewObj = this;

				objService.serviceId = this.serviceId;
				if(!timeframeId || timeframeId == undefined)
				{ timeframeId = tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.getCurrentTimeframeId(); }
				objService.timeframeId = timeframeId;
				
				objService.updatePlugins = updatePlugins;
				objService.pluginMessage = pluginMessage;

				// initialize the list of metrics we wish to retrieve data for
				var metricsList = new jsx3.util.List();
				metricsList.add("description");
				metricsList.add("version");
				metricsList.add("resourceType");
				metricsList.add("implType");
				metricsList.add("javaClassName");
				metricsList.add("jarFile");
				metricsList.add("namespace");
				metricsList.add("uddiIdentifier");
				metricsList.add("faults");
				metricsList.add("successes");
				metricsList.add("startDate");
				metricsList.add("availability");
				metricsList.add("uptime");
				metricsList.add("throughput");
				metricsList.add("avgResponseTime");
				metricsList.add("hitCount");
				metricsList.add("numNodesDeployedTo");
				metricsList.add("externalEndpoint");
				metricsList.add("environmentName");
				metricsList.add("environmentKey");
				metricsList.add("serviceAssemblyName");
				metricsList.add("serviceAssemblyKey");
				metricsList.add("serviceUnitName");
				metricsList.add("serviceUnitKey");

				objService.metricsList = metricsList;

                  //subscribe and call
      			objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetServicesSuccess);
      			objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetServicesError);
      			objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetServicesInvalid);
      			objService.doCall();
    		};

    		plugin.prototype.ongetServicesSuccess = function(objEvent) {
      			//var responseXML = objEvent.target.getInboundDocument();
     			//jsx3.log("Success","The service call was successful.");
				var serviceViewObj = objEvent.target.serviceViewObj;
     			var message = { initialized:true };
        		tibco.admin.monitormanage.general.PageBusUtils.publish(plugin.serviceInfoCacheSubject, message);
        		
        		if(objEvent.target.updatePlugins)
        		{
        			var serviceInfoCacheDoc = tibco.admin.Main.getServer().Cache.getDocument(plugin.serviceInfoCacheId);
        			var serviceInfoRecord = serviceInfoCacheDoc.getFirstChild();
        			var serviceName = serviceInfoRecord.getAttribute("name");
        			var resourceType = serviceInfoRecord.getAttribute("resourceType");
        			// notify the plugin components that they need to display
					var iter = serviceViewObj.getPluginList().iterator();
	    	        while(iter.hasNext()) {
	        	    	var obj = iter.next();
	        	       	if((jsx3.Class.forName(plugin.serviceTabInterfaceClassName).isInstance(obj)) || (jsx3.Class.forName(plugin.serviceHeaderInterfaceClassName).isInstance(obj)))
						{
							// if the plugin component is the "Provides/Consumes" tab then pass the entire parameter array message
							if(jsx3.Class.forName("tibco.admin.monitormanage.uicomponents.page.serviceView.tabContent.providesConsumes.ProvidesConsumes").isInstance(obj))
							{ obj.updateComponent(objEvent.target.pluginMessage); }
							else
							{ obj.updateComponent(serviceViewObj.serviceId, resourceType, serviceName); }
						}
	                }
	        	}
    		};

    		plugin.prototype.ongetServicesError = function(objEvent) {
      			var myStatus = objEvent.target.getRequest().getStatus();
      			jsx3.log("Error","The service call failed. The HTTP Status code is: " + myStatus);
    		};

    		plugin.prototype.ongetServicesInvalid = function(objEvent) {
      			jsx3.log("Invalid","The following message node just failed validation:\n\n" + objEvent.message);
    		};

        	//call this method to begin the service call (eg.service.callgetServiceInstances();)
    		plugin.prototype.callGetServiceInstances = function(timeframeId, updatePlugins) {
      			if(tibco.admin.Main.getServer().getEnv("MODE"))
    			{
					// mode is live
					var objService = tibco.admin.Main.loadService(this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/rules/serviceInstanceScreenRules.xml", "getServiceInstances");
					objService.setEndpointURL(plugin.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL("tibco/admin/monitormanage/uicomponents/page/serviceView/data/serviceInstanceScreenData.xml");
				}
				else
				{
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/rules/serviceInstanceScreenRules.xml"), "getServiceInstances", null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), "tibco/admin/monitormanage/uicomponents/page/serviceView/data/serviceInstanceScreenData.xml"));
				}

				objService.serviceInstanceId = this.serviceInstanceId;
				objService.serviceViewObj = this;
				if(!timeframeId)
				{ timeframeId = tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.getCurrentTimeframeId(); }
				objService.timeframeId = timeframeId;
				
				objService.updatePlugins = updatePlugins;

				// initialize the list of metrics we wish to retrieve data for
				var metricsList = new jsx3.util.List();
				metricsList.add("description");
                metricsList.add("implType");
                metricsList.add("version");
                metricsList.add("namespace");
                metricsList.add("resourceType");
				metricsList.add("deployedDate");
				metricsList.add("deployedBy");
				metricsList.add("messagingServer");
				metricsList.add("wsdlUrl");
				metricsList.add("schemaUrl");
				metricsList.add("faults");
				metricsList.add("successes");
				metricsList.add("startDate");
				metricsList.add("availability");
				metricsList.add("uptime");
				metricsList.add("throughput");
				metricsList.add("avgResponseTime");
				metricsList.add("hitCount");

                metricsList.add("environmentName");
				metricsList.add("environmentKey");
				metricsList.add("machineName");
				metricsList.add("machineKey");
				metricsList.add("nodeName");
				metricsList.add("nodeKey");
				metricsList.add("serviceAssemblyName");
				metricsList.add("serviceAssemblyKey");
				metricsList.add("serviceUnitName");
				metricsList.add("serviceUnitKey");

				objService.metricsList = metricsList;

      			//subscribe and call
      			objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.ongetServiceInstancesSuccess);
      			objService.subscribe(jsx3.net.Service.ON_ERROR, this.ongetServiceInstancesError);
      			objService.subscribe(jsx3.net.Service.ON_INVALID, this.ongetServiceInstancesInvalid);
      			objService.doCall();
    		};

    		plugin.prototype.ongetServiceInstancesSuccess = function(objEvent) {
      			//var responseXML = objEvent.target.getInboundDocument();
      			//jsx3.log("Success","The service call was successful.");
      			//alert("in service instance success");
      			//alert(tibco.admin.Main.getServer().Cache.getDocument(plugin.serviceInstanceInfoCacheId));
      			//objEvent.target.serviceViewObj.buildServiceInstanceScreen();
      			var serviceViewObj = objEvent.target.serviceViewObj;
      			var message = { initialized:true };
        		tibco.admin.monitormanage.general.PageBusUtils.publish(plugin.serviceInstanceInfoCacheSubject, message);
        		
        		if(objEvent.target.updatePlugins)
        		{
        			// notify the plugin components that they need to display
        			var serviceInfoCacheDoc = tibco.admin.Main.getServer().Cache.getDocument(plugin.serviceInstanceInfoCacheId);
        			var serviceInfoRecord = serviceInfoCacheDoc.getFirstChild();
        			var serviceName = serviceInfoRecord.getAttribute("name");
        			var resourceType = serviceInfoRecord.getAttribute("resourceType");
					var iter = serviceViewObj.getPluginList().iterator();
	    	        while(iter.hasNext()) {
	        	    	var obj = iter.next();
	        	       	if((jsx3.Class.forName(plugin.serviceInstanceTabInterfaceClassName).isInstance(obj)) || (jsx3.Class.forName(plugin.serviceInstanceHeaderInterfaceClassName).isInstance(obj)))
						{ obj.updateComponent(serviceViewObj.serviceInstanceId, resourceType, serviceName); }
	                }
	        	}
    		};

    		plugin.prototype.ongetServiceInstancesError = function(objEvent) {
      			var myStatus = objEvent.target.getRequest().getStatus();
      			jsx3.log("Error","The service call failed. The HTTP Status code is: " + myStatus);
    		};

    		plugin.prototype.ongetServiceInstancesInvalid = function(objEvent) {
      			jsx3.log("Invalid","The following message node just failed validation:\n\n" + objEvent.message);
    		};

        });